export default class GameEvent{
    constructor(){
        this.handles = {}
    }
    addEvent(eventName, fn){
        if(!this.handles[eventName]){
            this.handles[eventName] = [fn]
            return
        }
        this.handles.push(fn)
    }
    trigger(eventName){
        this.handles[eventName].forEach(v=>v())
    }
    removeEvent(eventName, fn){
        if(!this.handles[eventName]) return 
        this.handles[eventName].filter(item=>item !== fn)
    }
}